package com.css.fxfzaqbz.modules.domain.service.impl;

import com.css.fxfzaqbz.modules.data.entity.AidedAnalyse;
import com.css.fxfzaqbz.modules.data.entity.DisposeManager;
import com.css.fxfzaqbz.modules.data.repository.AidedAnalyseRepository;
import com.css.fxfzaqbz.modules.data.repository.DisposeManagerRepository;
import com.css.fxfzaqbz.modules.domain.service.AnalysisService;
import com.css.fxfzaqbz.util.PlatformObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AnalysisServiceImpl implements AnalysisService {
    @Resource
    AidedAnalyseRepository aidedAnalyseRepository;
    @Resource
    DisposeManagerRepository disposeManagerRepository;
    @Override
    public List<AidedAnalyse> getFzByIaId(String iaId) {
        List<AidedAnalyse> aidedAnalyses = aidedAnalyseRepository.getFzByIaId(iaId);
        for (AidedAnalyse aidedAnalyse : aidedAnalyses) {
            List<String> strings = new ArrayList<>();
            if (!PlatformObjectUtils.isEmpty(aidedAnalyse.getDescription())) {
                String[] split = aidedAnalyse.getDescription().split("&&");
                for (String s : split) {
                    strings.add(s);
                }
                aidedAnalyse.setDescriptions(strings);
            }
        }
        return aidedAnalyses;
    }

    @Override
    public List<DisposeManager> getCzByIaId(String iaId) {
        return disposeManagerRepository.getCzByIaId(iaId);
    }

    @Override
    public List<AidedAnalyse> getAnalysisByIaId(String iaId) {
        return aidedAnalyseRepository.getAnalysisByIaId(iaId);
    }

    @Override
    public List<DisposeManager> getQcCzByIaId(String iaId) {
        return disposeManagerRepository.getQcCzByIaId(iaId);
    }

    @Override
    public List<DisposeManager> getCzByType(String lx, String iaId) {
        return disposeManagerRepository.getCzByType(lx,iaId);
    }

    @Override
    public List<DisposeManager> getAnalysisByFatherLabel(String dmLabel, String iaId,String type) {
        return disposeManagerRepository.getAnalysisByFatherLabel(dmLabel,iaId,type);
    }
}
